package com.example.jdbc.service;

import java.util.List;

import javax.annotation.Resource;

import com.example.jdbc.bean.User;
import org.springframework.stereotype.Service;

import com.example.jdbc.bean.LearnResource;
import com.example.jdbc.dao.userDao;

@Service
public class UserServiceImpl implements UserService {

	@Resource
	userDao userDao;

	@Override
	public List<LearnResource> findAll() {
		return userDao.listAllUser();
	}

	@Override
	public void testsave(LearnResource use) {
		int i=userDao.insertUser(use);
		if(i!=1){
			System.out.println("新增数据失败");
		}
		System.out.println("新增数据成功");
	}

	@Override
	public int updateById(LearnResource user) {
		LearnResource resource = userDao.selectUser(user.getId());
		if (resource == null) {
			System.out.println("没有该用户！！！！");
			return 0;
		}
        return userDao.updateUser(user);
	}

	@Override
	public LearnResource findOne(int id) {
		return userDao.selectUser(id);
	}

	@Override
	public int delete(int id) {
		return userDao.deleteUser(id);
	}

	@Override
	public User queryUserByName(String title) {
		return userDao.selectUser(title);
	}
}
